package com.secondhand.controller;

import com.secondhand.domain.comment;
import com.secondhand.domain.good;
import com.secondhand.service.Impl.commentServiceImpl;
import com.secondhand.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("二手交易相关接口")
@Log4j2
@RestController
@RequestMapping("/comment")
public class commentController {

    @Autowired
    commentServiceImpl commentService;

    @ApiOperation("添加评论")
    @PostMapping("/add")
    public AjaxResult register(@RequestBody comment comment) {
        boolean result = commentService.addComment(comment);
        return AjaxResult.success("添加评论成功",result);
    }

    @ApiOperation("获取评论列表")
    @GetMapping("/list")
    @ApiImplicitParam(name = "goodid", value = "商品id", required = true, dataType = "int")
    public AjaxResult getSiteListById(int goodid) {
        List<comment> result = commentService.gainCommentsList(goodid);
        return AjaxResult.success("获取商品列表",result);
    }
}
